import com.java.example.*;
import com.java.example.org.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentController studentController =
                applicationContext.getBean("studentController",StudentController.class);
        //3,使用Bean对象
        studentController.sayHi();
    }


    public static void main6(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        Student student =
                applicationContext.getBean("student",Student.class);
        //3,使用Bean对象
        System.out.println(student.getStudentName());
    }
    public static void main5(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentConfiguration studentConfiguration =
                applicationContext.getBean("studentConfiguration",StudentConfiguration.class);
        //3,使用Bean对象
        studentConfiguration.sayHi();
    }

    public static void main4(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentComponent studentComponent =
                applicationContext.getBean("studentComponent",StudentComponent.class);
        //3,使用Bean对象
        studentComponent.sayHi();
    }

    public static void main3(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentRepository studentRepository =
                applicationContext.getBean("studentRepository",StudentRepository.class);
        //3,使用Bean对象
        studentRepository.sayHi();
    }

    public static void main2(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentService studentService =
                applicationContext.getBean("studentService",StudentService.class);
        //3,使用Bean对象
        studentService.sayHi();
    }

    public static void main1(String[] args) {
        //1，获取Spring上下文
        ApplicationContext applicationContext =
                new ClassPathXmlApplicationContext("spring-config.xml");
        //2,得到Bean对象
        StudentController studentController =
                applicationContext.getBean("studentController",StudentController.class);
        //3,使用Bean对象
        studentController.sayHi();
    }
}
